﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
/// <summary>
///WebForm 的摘要说明
/// </summary>
public class WebForm:WebFormBase
{
    //protected const string SessionUser = "UserSession";
    /// <summary>
    /// 
    /// </summary>
    /// <param name="e"></param>
    //protected override void OnInit(EventArgs e)
    //{
    //    string applicationPath = base.Request.ApplicationPath;
    //    if (!applicationPath.EndsWith("/"))
    //    {
    //        applicationPath = applicationPath + "/";
    //    }
    //    //登陆继续往下执行
    //    if (this.Session[SessionUser] == null)
    //    {
    //        string str2 = base.Request.RawUrl.ToString();
    //        RedirectNewURL(string.Format("{0}manager/Default.aspx?url={1}", applicationPath, str2));
    //        base.Response.End();
    //    }
    //    base.OnInit(e);
    //}

    public string GetFileName(Uri url)
    {
        string path = url.AbsolutePath;
        int index = path.LastIndexOf("/");
        return path.Substring(index + 1, path.Length - index - 1);
    }

    protected List<int> GetIdToList(string id) {
        List<int> intds = new List<int>();
        try
        {
            string[] ids = id.Split(',');
            foreach (var str in ids)
            {
                int tmp = 0;
                if (int.TryParse(str, out tmp) && tmp > 0)
                {
                    intds.Add(tmp);
                }
            }
        }
        catch { }
        return intds;
    }
    protected void SetClientDate(string clientId, DateTime time)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<script type='text/javascript'>");
        //sb.Append(string.Format("$(document).ready(function(){$('#{0}').datepicker('setDate', new Date({1},{2},{3}));});", clientId, time.Year, (time.Month - 1), time.Day));
        sb.Append("$(document).ready(function(){$('#" + clientId + "').datepicker('setDate', new Date(" + time.Year + "," + (time.Month - 1) + "," + time.Day + "));});");
        sb.Append("</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), clientId, sb.ToString());
    }
}